# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=eww
pkgver=0.4.0
pkgrel=1
pkgdesc="ElKowars wacky widgets"
url="https://elkowar.github.io/eww/"
arch="aarch64 x86_64"  # blocked by rustup
license="MIT"
# XXX: eww requires rust nightly, so we cannot build it with our rustc.
#  Don't move this aport out of the testing repo until it can be built with
#  our rust!
makedepends="
	cargo-auditable
	gtk+3.0-dev
	gtk-layer-shell-dev
	rustup
	"
subpackages="$pkgname-dbg"
source="https://github.com/elkowar/eww/archive/refs/tags/v$pkgver/eww-$pkgver.tar.gz
	update-cargo-lock.patch
	"

export CARGO_HOME="$srcdir/.cargo"
export RUSTUP_HOME="$srcdir/.rustup"
export PATH="$CARGO_HOME/bin:$PATH"

export RUSTFLAGS="$RUSTFLAGS -Ctarget-feature=-crt-static"
# Reduce binary size (7.1 -> 4.1 MiB for 0.2.0_git20220215).

prepare() {
	default_prepare

	rustup-init \
		--target "$CARCH-unknown-linux-musl" \
		--default-toolchain nightly \
		--profile minimal \
		--no-modify-path \
		-y

	cargo fetch --target="$CARCH-unknown-linux-musl" --locked
}

build() {
	cargo auditable build --frozen --release --no-default-features --features=wayland
}

check() {
	cargo test --frozen
}

package() {
	install -D -m755 target/release/eww -t "$pkgdir"/usr/bin/
}

sha512sums="
1979251848fb21dac60b60fb149481aea3201c62a56b34cd2d5fbc8da53a4e9f019db393c9bcd31936f4cd739de295110217b5ecfef734b35d0f1c5cb785e646  eww-0.4.0.tar.gz
da52a2dfa5e87a0b4c95a118ea1c1f61757ec75a01c79d4f194728eb9c9580fc4be3984205a00bd15977a5530b49bbfdfba57cb7645718b00b9f87fe21f0a445  update-cargo-lock.patch
"
